import ast
import onnxruntime as ort


if __name__ == '__main__':
    filename = ""

    # 加载 ONNX 模型
    session = ort.InferenceSession("D:\\Workspace\\deal\\yolov5s.onnx", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])

    modelmeta = session.get_modelmeta()

    print("Model meta:\n")

    print(modelmeta)

    print("===========================================================================================")

    data = modelmeta.custom_metadata_map

    print("Model meta - custom_metadata_map:\n")

    print(data)

    print("===========================================================================================")

    names_string = data.get("names")

    print("Model meta - custom_metadata_map - names:\n")

    names_dict = ast.literal_eval(names_string)

    for key, value in names_dict.items():
        #
        # 打印 onnx 文件中支持的标签
        #
        print(key, value)

    print("===========================================================================================")







